﻿using Gx.Common;
using Gx.Dal.Manage;
using Gx.Model.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Gx.Dal.Shared
{
    public static class UserContext
    {

        //private static UserContext _instance;
        //public static UserContext Current
        //{
        //    get
        //    {
        //        if (_instance == null)
        //        {
        //            _instance = new UserContext();
        //        }
        //        return _instance;
        //    }
        //}


        public static B_EmployeeInfo CurrentUser
        {
            get
            {
                return GetCurrentUser();
            }
        }
        public static B_EmployeeInfo GetCurrentUser()
        {
            B_EmployeeInfoDal dal = new B_EmployeeInfoDal();
            return dal.GetB_EmployeeInfoModel(LoginHelper.GetUserId());
        }

        public static int CompanyId
        {
            get
            {
                if (CurrentUser != null)
                {
                    return CurrentUser.CompanyId;
                }
                return 0;
            }
        }

        public static string CompanyName
        {
            get
            {
                BaseDal<LKCompany> companydal = new BaseDal<LKCompany>();
                var company = companydal.Get(CompanyId);
                return company != null ? company.CompanyName : string.Empty;
            }
        }

        public static int RoleId
        {
            get
            {
                return LoginHelper.GetRoleId();
            }
        }

        public static int UserId
        {
            get
            {
                return LoginHelper.GetUserId();
            }
        }
    }
}
